package edu.njust.Service.Room.impl;

import edu.njust.Service.Room.RoomService;
import edu.njust.dao.RoomMapper;
import edu.njust.domain.Room;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {
    @Autowired
    private RoomMapper roomMapper;
    @Override
    public boolean deleteById(int id) {
        return roomMapper.deleteById(id)>0;
    }

    @Override
    public boolean insertAll(Room room) {
        return roomMapper.insertAll(room)>0;
    }

    @Override
    public Room selectById(int id) {
        Room room=roomMapper.selectById(id);
        return room;
    }

    @Override
    public boolean updateById(Room room) {
        return roomMapper.updateById(room)>0;
    }

    /*
        roomNumber 房间数字编号
        start 开始页数
        pageSize 每页页数
     */
    @Override
    public List<Room> pageFuzzyselect(String roomNumber, int start, int pageSize) {
        List<Room> rooms=roomMapper.pageFuzzyselect(roomNumber,(start-1)*pageSize,pageSize);
        return rooms;
    }

    @Override
    public int countFuzzyselect(String roomNumber) {
        return roomMapper.countFuzzyselect(roomNumber);
    }

    @Override
    public List<Room> selectAll() {
        return roomMapper.selectAll();
    }

    @Override
    public List<Room> selectByLeveId(int id) {
        return roomMapper.selectByLeveId(id);
    }

    @Override
    public boolean selectYZ(String roomNumber) {
        return roomMapper.selectYZ(roomNumber)>0;
    }

    @Override
    public boolean updateByIdToRoomState(Room room) {
        return roomMapper.updateByIdToRoomState(room)>0;
    }

    @Override
    public List<Room> selectInformation(String roomNumber) {
        List<Room> rooms=roomMapper.selectInformation(roomNumber);
        return rooms;
    }

    @Override
    public List<Room> levelSelectInformation(int guestRoomLevelID) {
        List<Room> rooms=roomMapper.levelSelectInformation(guestRoomLevelID);
        return rooms;
    }

    @Override
    public int countselectByLeveId(int id) {
        int count = roomMapper.countselectByLeveId(id);
        return count;
    }

    @Override
    public boolean updateroomStateone(int id) {
        return roomMapper.updateroomStateone(id)>0;
    }

    @Override
    public boolean updateroomStatetwo(int id) {
        return roomMapper.updateroomStatetwo(id)>0;
    }

    @Override
    public boolean updateroomStatethree(int id) {
        return roomMapper.updateroomStatethree(id)>0;
    }

    @Override
    public int selectidbyname(String roomNumber) {
        return roomMapper.selectidbyname(roomNumber);
    }



}
